package com.villaday.idf.fragment3;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.viewpager.widget.ViewPager;
import androidx.core.widget.NestedScrollView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Html;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.atuan.datepickerlibrary.CalendarUtil;
import com.atuan.datepickerlibrary.DatePopupWindow;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.gson.Gson;
import com.villaday.idf.R;
import com.villaday.idf.activity.BackHandlerHelper;
import com.villaday.idf.activity.FragmentBackHandler;
import com.villaday.idf.activity.InstallationActivity;
import com.villaday.idf.activity.OrderInputActivity;
import com.villaday.idf.activity.WineShopDetailsActivity;
import com.villaday.idf.adapter3.FindHousBrandListAdapter;
import com.villaday.idf.adapter3.FindHouseWindShopNearAdapter;
import com.villaday.idf.adapter3.FindHouseWineShopDetailsAdapter;
import com.villaday.idf.adapter3.PopularHouseAdapter;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.base.BaseFragment;
import com.villaday.idf.custom.CommonPopupWindow;
import com.villaday.idf.custom.LoadDialog;
import com.villaday.idf.custom.bannerUtil.BannerUtils;
import com.villaday.idf.custom.pop.SharePop;
import com.villaday.idf.model.RefreshtokenEntity;
import com.villaday.idf.model3.AllPostersEntity;
import com.villaday.idf.model3.BrandListEntity;
import com.villaday.idf.model3.DataEntity;
import com.villaday.idf.model3.HotelDetailsEntity;
import com.villaday.idf.model3.HotelRoomEntity;
import com.villaday.idf.model3.HotelSimilyEntity;
import com.villaday.idf.util.Constant;
import com.villaday.idf.util.LogUtil;
import com.villaday.idf.util.OkHttpUtil;
import com.villaday.idf.util.PhoneUtil;
import com.villaday.idf.util.ShareUtils;
import com.villaday.idf.util.SharedPreferencesUtil;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;
import butterknife.Unbinder;
import byc.imagewatcher.ImageWatcher;
import io.reactivex.functions.Consumer;
import razerdp.basepopup.BasePopupWindow;

import static com.atuan.datepickerlibrary.CalendarUtil.DataBoolean;

public class WineShopDetailsFragment extends BaseFragment implements FragmentBackHandler {


    @BindView(R.id.bus_ws)
    BannerUtils busWs;
    @BindView(R.id.tv_guide)
    TextView tvGuide;
    @BindView(R.id.tv_ws_title)
    TextView tvWsTitle;
    @BindView(R.id.tv_ws_title_eng)
    TextView tvWsTitleEng;
    @BindView(R.id.ll_fhwsd_name)
    LinearLayout llFhwsdName;
    @BindView(R.id.tv_fhwsd_type)
    TextView tvFhwsdType;
    @BindView(R.id.tv_fhwsd_label)
    TextView tvFhwsdLabel;
    @BindView(R.id.tv_fhwsd_labe2)
    TextView tvFhwsdLabe2;
    @BindView(R.id.ll_ws_type)
    LinearLayout llWsType;
    @BindView(R.id.tv_fhwsd_num)
    TextView tvFhwsdNum;
    @BindView(R.id.iv_fhwsd_star0)
    ImageView ivFhwsdStar0;
    @BindView(R.id.iv_fhwsd_star1)
    ImageView ivFhwsdStar1;
    @BindView(R.id.iv_fhwsd_star2)
    ImageView ivFhwsdStar2;
    @BindView(R.id.iv_fhwsd_star3)
    ImageView ivFhwsdStar3;
    @BindView(R.id.iv_fhwsd_star4)
    ImageView ivFhwsdStar4;
    @BindView(R.id.iv_fhwsd_star5)
    ImageView ivFhwsdStar5;
    @BindView(R.id.iv_fhwsd_star6)
    ImageView ivFhwsdStar6;
    @BindView(R.id.iv_fhwsd_star7)
    ImageView ivFhwsdStar7;
    @BindView(R.id.iv_fhwsd_star8)
    ImageView ivFhwsdStar8;
    @BindView(R.id.iv_fhwsd_star9)
    ImageView ivFhwsdStar9;
    @BindView(R.id.iv_fhwsd_star10)
    ImageView ivFhwsdStar10;
    @BindView(R.id.vw_fhwsd_on)
    View vwFhwsdOn;
    @BindView(R.id.tv_fhwsd_reduce)
    TextView tvFhwsdReduce;
    @BindView(R.id.tv_fhwsd_reduce_add)
    TextView tvFhwsdReduceAdd;
    @BindView(R.id.ll_ws_type_content)
    LinearLayout llWsTypeContent;
    @BindView(R.id.vw_ws_type_content)
    View vwWsTypeContent;
    @BindView(R.id.tv_fhwsd_address)
    TextView tvFhwsdAddress;
    @BindView(R.id.ll_fhwsd_address)
    LinearLayout llFhwsdAddress;
    @BindView(R.id.tv_fhwsd_intro)
    TextView tvFhwsdIntro;
    @BindView(R.id.tv_fhwsd_more)
    TextView tvFhwsdMore;
    @BindView(R.id.rl_fhwsd_install)
    RelativeLayout rlFhwsdInstall;
    @BindView(R.id.tv_fhwsd_in)
    TextView tvFhwsdIn;
    @BindView(R.id.tv_fhwsd_day)
    TextView tvFhwsdDay;
    @BindView(R.id.tv_fhwsd_out)
    TextView tvFhwsdOut;
    @BindView(R.id.ll_fhwsd_user)
    LinearLayout llFhwsdUser;
    @BindView(R.id.tv_fhwsd_bottom1)
    TextView tvFhwsdBottom1;
    @BindView(R.id.tv_fhwsd_bottom2)
    TextView tvFhwsdBottom2;
    @BindView(R.id.tv_fhwsd_bottom3)
    TextView tvFhwsdBottom3;
    @BindView(R.id.tv_fhwsd_bottom4)
    TextView tvFhwsdBottom4;
    @BindView(R.id.tv_fhwsd_bottom5)
    TextView tvFhwsdBottom5;
    @BindView(R.id.ll_fhwsd_label)
    LinearLayout llFhwsdLabel;
    @BindView(R.id.rv_fhwsd)
    RecyclerView rvFhwsd;
    @BindView(R.id.tv_ws_more)
    TextView tvWsMore;
    @BindView(R.id.iv_ws_more)
    ImageView ivWsMore;
    @BindView(R.id.ll_ws_more)
    LinearLayout llWsMore;
    @BindView(R.id.vw_fhwsd_near)
    View vwNear;
    @BindView(R.id.tv_fhwsd_near)
    TextView tvFhwsdNear;
    @BindView(R.id.rv_fhwsd_near)
    RecyclerView rvFhwsdNear;
    @BindView(R.id.vw_fhwsd_similar)
    View vwFhwsdSimilar;
    @BindView(R.id.tv_fhwsd_similar)
    TextView tvFhwsdSimilar;
    @BindView(R.id.rv_fhwsd_similar)
    RecyclerView rvFhwsdSimilar;
    @BindView(R.id.svu_fhwsd)
    NestedScrollView svuFhwsd;
    @BindView(R.id.srl_fwsdh)
    SwipeRefreshLayout srlFwsdh;
    @BindView(R.id.ll_fwd)
    RelativeLayout llFwd;
    @BindView(R.id.tv_fhwsd_share)
    TextView tvFhwsdShare;
    @BindView(R.id.ll_fhwsd_share)
    LinearLayout llFhwsdShare;
    @BindView(R.id.tv_fhwsd_look)
    TextView tvFhwsdLook;
    @BindView(R.id.ll_fhwsd_bottom)
    LinearLayout llFhwsdBottom;
    @BindView(R.id.vw_wd)
    View vwWd;
    Unbinder unbinder;


    private CommonPopupWindow popuDetails;
    private FindHouseWindShopNearAdapter findHouseWindShopNearAdapter;
    private int mMaxHouseNum = 5;

    /**
     * 住离模块
     */
    private int startGroup = -1;
    private int endGroup = -1;
    private int startChild = -1;
    private int endChild = -1;
    private String checkInDate = "";//入住时间
    private String checkOutDate = "";//离开时间
    private DatePopupWindow builder;
    private TextView tvGuideMore;
    private HotelSimilyEntity mHotelSimilyEntity;
    private LinearLayoutManager linearLayoutManager;
    private LoadDialog loadDialog;
    private int mHearHeight;
    private List<BrandListEntity.BodyBean.ListBean> mBrandList;
    private FindHousBrandListAdapter mFindHousBrandListAdapter;


    private List<HotelRoomEntity.BodyBean> listRooms = new ArrayList<>();
    private FindHouseWineShopDetailsAdapter findHouseWineShopDetailsAdapter;
    private List<HotelSimilyEntity.BodyBean.ListBean> list = new ArrayList<>();
    private HotelRoomEntity hotelRoomEntity;
    private boolean hotelRoomIsTall = false;
    private boolean hotelVip = false;
    private List<ImageView> listStar = new ArrayList<>();

    private int mRvPosition = 0;
    private int mRvItemPosition = 0;


    private String hotelID = "-1";
    private HotelDetailsEntity.BodyBean mDetailsBody;
    int type = 0;

    private ImageWatcher vImageWatcher;
    private AllPostersEntity.BodyBean allPostersEntity;
    public static WineShopDetailsFragment instance(String hotelID) {
        WineShopDetailsFragment wineShopDetailsFragment = new WineShopDetailsFragment();

        Bundle bundle = new Bundle();
        bundle.putString("hotelID", hotelID);
        wineShopDetailsFragment.setArguments(bundle);
        return wineShopDetailsFragment;
    }

    @Override
    protected int getViewResId() {
        return R.layout.fragment_wineshop_details;
    }
    private void initSharePop() {
        mRxManager.on("sharepopEntity", new Consumer<AllPostersEntity.BodyBean>() {

            @Override
            public void accept(AllPostersEntity.BodyBean bodyBean) throws Exception {

                allPostersEntity = bodyBean;
            }
        });
        mRxManager.on("sharepop", new Consumer<ImageWatcher>() {
            @Override
            public void accept(ImageWatcher imageWatcher) throws Exception {
                vImageWatcher = imageWatcher;
                vImageWatcher.setImageWatcherOndismiss(new ImageWatcher.ImageWatcherDiss() {
                    @Override
                    public void onImageWatcherDiss() {
                        if (allPostersEntity!=null){
                            SharePop sharePop = new SharePop(WineShopDetailsFragment.this,getActivity(), getActivity(), allPostersEntity);
                            sharePop.showPopupWindow();
                        }
                    }
                });
            }
        });
    }


    @Override
    protected void loadData() {
        super.loadData();
        hotelID = getArguments().getString("hotelID");
        LogUtil.jLog().e(hotelID + "");
        //初始化相关数据
        initData();
        //初始化Banner
        initBanner();
        //初始化详情
        getHotelDetails();
        //初始化列表
        initRoomRv();
        getRoom();
        //初始化相似列表
        initSimilyRv();
        getSimilar();
        //初始化同品牌酒店
        initBranList();
        getBrandList();
    }


    public void setSkip(int type, final int scrollY) {
        switch (type) {
            case 0:
                svuFhwsd.setScrollY(0);
                break;
            case 1:
                LogUtil.jLog().e(getHeight(rlFhwsdInstall) + "   "
                        + getHeight(llFhwsdLabel) + "    "
                        + getHeight(llFhwsdUser) + "   "
                        + getHeight(rvFhwsd));
                mHearHeight = PhoneUtil.dp2px(getActivity(), 265)
                        + getHeight(rlFhwsdInstall) + getHeight(llFhwsdLabel) + getHeight(llFhwsdUser) + getHeight(rvFhwsd);
//                svuFhwsd.setScrollY(mHearHeight);
                svuFhwsd.smoothScrollTo(0, mHearHeight);
                break;
            case 2:
                svuFhwsd.setScrollY(scrollY);
                break;
        }
    }


    /**
     * 初始化详情数据
     */
    private void initData() {
        //是否是Vip
        RefreshtokenEntity.BodyBean roleInfo = SharedPreferencesUtil.getRoleInfo(getContext());
        LogUtil.jLog().e(new Gson().toJson(roleInfo));
        if (roleInfo != null && !roleInfo.getMember().getType().equals("0")) {
            hotelVip = true;
        }

        if (DataBoolean(System.currentTimeMillis())) {
            checkInDate = CalendarUtil.FormatDateString(System.currentTimeMillis() + (1000 * 3600 * 24));
            checkOutDate = CalendarUtil.FormatDateString(System.currentTimeMillis() + (1000 * 3600 * 48));
        } else {
            checkInDate = CalendarUtil.FormatDateString(System.currentTimeMillis());
            checkOutDate = CalendarUtil.FormatDateString(System.currentTimeMillis() + (1000 * 3600 * 24));
        }

        tvFhwsdIn.setText(CalendarUtil.FormatChangeString(checkInDate));
        tvFhwsdOut.setText(CalendarUtil.FormatChangeString(checkOutDate));
        tvFhwsdDay.setText("1晚");

        mHearHeight = PhoneUtil.dp2px(getActivity(), 265)
                + getHeight(rlFhwsdInstall) + getHeight(llFhwsdLabel) + getHeight(llFhwsdUser) + getHeight(rvFhwsd);

        //星星
        listStar.add(ivFhwsdStar0);
        listStar.add(ivFhwsdStar1);
        listStar.add(ivFhwsdStar2);
        listStar.add(ivFhwsdStar3);
        listStar.add(ivFhwsdStar4);
        listStar.add(ivFhwsdStar5);
        listStar.add(ivFhwsdStar6);
        listStar.add(ivFhwsdStar7);
        listStar.add(ivFhwsdStar8);
        listStar.add(ivFhwsdStar9);
        //刷新
        srlFwsdh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                //查询酒店详情
                getHotelDetails();
                //查询酒店房型列表
                getRoom();
                //得到相似酒店
                getSimilar();
                //得到同品牌酒店
                getBrandList();
            }
        });

        svuFhwsd.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView nestedScrollView, int i, int i1, int i2, int i3) {
                if (i1 != 0) {
                    SharedPreferencesUtil.saveDistance(getActivity(), i1);
                }
                if (i1 >= mHearHeight) {
                    type = 1;
                } else {
                    type = 0;
                }
                onScrollWineListener.onScroll(i1, mHearHeight, type);
            }
        });

        initSharePop();
    }

    private void getHotelDetails() {
        Map<String, String> map = new HashMap<>();
        OkHttpUtil.getJSON(getActivity(), Constant.URL.hotelsDetails + hotelID, map, new OkHttpUtil.OnDataListener() {

            @Override
            public void onResponse(String url, String json) {
                try {
                    LogUtil.jLog().e(json);
                    if (!TextUtils.isEmpty(json)) {
                        HotelDetailsEntity mHotelDetailsEntity = new Gson().fromJson(json, HotelDetailsEntity.class);
                        if (mHotelDetailsEntity.getCode().equals(Constant.Strings.SUC)) {
                            mDetailsBody = mHotelDetailsEntity.getBody();

                            tvWsTitle.setText(mDetailsBody.getName());
                            tvFhwsdType.setText(mDetailsBody.getLevelName());
                            if (mDetailsBody.getEstablishmentDate() != null && !mDetailsBody.getEstablishmentDate().equals("")) {
                                tvFhwsdLabel.setVisibility(View.VISIBLE);
                                tvFhwsdLabel.setText(mDetailsBody.getEstablishmentDate() + "开业");
                            }

                            if (mDetailsBody.getRenovationDate() != null && !mDetailsBody.getRenovationDate().equals("")) {
                                tvFhwsdLabe2.setVisibility(View.VISIBLE);
                                tvFhwsdLabe2.setText(mDetailsBody.getRenovationDate() + "装修");
                            }


                            if (mDetailsBody.getBrokerAgeAmountValue() != null && hotelVip) {
                                tvFhwsdShare.setText(Html.fromHtml("分享赚 &yen;" + mDetailsBody.getBrokerAgeAmountValue() + "起"));
                            } else {
                                llFhwsdShare.setVisibility(View.GONE);
                            }

                            //是否是国外
                            if (mDetailsBody.getDistrict() == 3) {//国外
                                tvWsTitleEng.setVisibility(View.VISIBLE);
                                tvWsTitleEng.setText(mDetailsBody.getNameEn());
                                tvFhwsdAddress.setText(mDetailsBody.getAddressEn());
                            } else {
                                tvFhwsdAddress.setText(mDetailsBody.getAddress());
                            }


                            //增加减标签
                            if (hotelVip && mDetailsBody.getAddBrokerageAmountValue() != null) {
                                tvFhwsdReduce.setVisibility(View.VISIBLE);
                                tvFhwsdReduce.setText(Html.fromHtml("立返&yen;" + mDetailsBody.getBrokerAgeAmountValue() + "起"));
                            }

                            //增加加返标签
                            if (hotelVip && mDetailsBody.getAddBrokerageAmountValue() != null && !mDetailsBody.getAddBrokerageAmountValue().equals("0")) {
                                tvFhwsdReduceAdd.setVisibility(View.VISIBLE);
                                tvFhwsdReduceAdd.setText(Html.fromHtml("加返&yen;" + mDetailsBody.getAddBrokerageAmountValue() + "起"));
                            }else {
                                
                            }

                            //星星标签
                            int score = mDetailsBody.getScore();
                            if (score == 0) {
                                tvFhwsdNum.setVisibility(View.GONE);
                            } else {
                                vwFhwsdOn.setVisibility(View.VISIBLE);
                                tvFhwsdNum.setText(score + "");
                            }

                            for (int i = 0; i < score; i++) {
                                if (score > i) {
                                    listStar.get(i).setVisibility(View.VISIBLE);
                                }
                            }

                            //标签
                            List<HotelDetailsEntity.BodyBean.FiltersBean> filters = mDetailsBody.getFilters();
                            for (int i = 0; i < filters.size(); i++) {
                                switch (filters.get(i).getType()) {
                                    case "1":
                                        tvFhwsdBottom1.setVisibility(View.VISIBLE);
                                        tvFhwsdBottom1.setText(filters.get(i).getName());
                                        break;
                                    case "2":
                                        tvFhwsdBottom2.setVisibility(View.VISIBLE);
                                        tvFhwsdBottom2.setText(filters.get(i).getName());
                                        break;
                                    case "3":
                                        tvFhwsdBottom3.setVisibility(View.VISIBLE);
                                        tvFhwsdBottom3.setText(filters.get(i).getName());
                                        break;
                                    case "4":
                                        tvFhwsdBottom4.setVisibility(View.VISIBLE);
                                        tvFhwsdBottom4.setText(filters.get(i).getName());
                                        break;
                                    case "5":
                                        tvFhwsdBottom5.setVisibility(View.VISIBLE);
                                        tvFhwsdBottom5.setText(filters.get(i).getName());
                                        break;
                                }
                            }

                            //简介
                            if (mDetailsBody.getIntroduce() != null && mDetailsBody.getIntroduce().length() != 0
                                    && !mDetailsBody.getIntroduce().equals("null")) {
                                tvFhwsdIntro.setText(mDetailsBody.getIntroduce());
                            } else {
                                tvFhwsdIntro.setVisibility(View.GONE);
                            }

                            if (mDetailsBody.getIntroduce() != null && tvFhwsdIntro.getLayout().getLineCount() == 2
                                    || mDetailsBody.getIntroduce().length() > 47) {
                                tvFhwsdMore.setVisibility(View.VISIBLE);
                            } else {
                                tvFhwsdMore.setVisibility(View.GONE);
                            }

                            //Banner
                            if (null != mDetailsBody.getImageURLs()) {
                                List<String> urlString = new ArrayList<>();
                                List<String> idString = new ArrayList<>();
                                final List<String> imageURLs = mDetailsBody.getImageURLs();

                                for (int i = 0; i < imageURLs.size(); i++) {
                                    urlString.add(mDetailsBody.getImageURLs().get(i));
                                    idString.add("空的");
                                }
                                busWs.setData(R.layout.view_image, urlString, idString);
                                busWs.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                                    @Override
                                    public void onPageScrolled(int i, float v, int i1) {

                                        if (v % 1 > 0.1 && imageURLs.size() > i + 1) {
                                            tvGuide.setText(i + 2 + "/" + imageURLs.size());
                                        } else {
                                            tvGuide.setText(i + 1 + "/" + imageURLs.size());
                                        }
                                        if (SharedPreferencesUtil.getDistance(getActivity()) != 0 && SharedPreferencesUtil.getDistance(getActivity()) != -1) {
                                            svuFhwsd.setScrollY(SharedPreferencesUtil.getDistance(getActivity()));
                                        }
                                    }

                                    @Override
                                    public void onPageSelected(int i) {

                                    }

                                    @Override
                                    public void onPageScrollStateChanged(int i) {
                                    }
                                });
                            }
                        }
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(String url, String error) {

            }
        });
    }


    /**
     * 点击事件
     *
     * @param view
     */
    @OnClick({R.id.tv_fhwsd_bottom1, R.id.tv_fhwsd_bottom2, R.id.tv_fhwsd_bottom3, R.id.tv_fhwsd_bottom4
            , R.id.ll_fhwsd_share, R.id.tv_fhwsd_look, R.id.ll_ws_type, R.id.ll_fhwsd_address, R.id.tv_fhwsd_more
            , R.id.ll_fhwsd_user, R.id.ll_ws_more})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_fhwsd_bottom1:
                showDialog();
                if (tvFhwsdBottom1.getCurrentTextColor() == getResources().getColor(R.color.colorTextBlack)) {
                    tvFhwsdBottom1.setTextColor(getResources().getColor(R.color.colorF73637));
                    tvFhwsdBottom1.setBackgroundResource(R.drawable.shape_stroke_pink_solid_white_40);
                } else {
                    tvFhwsdBottom1.setTextColor(getResources().getColor(R.color.colorTextBlack));
                    tvFhwsdBottom1.setBackgroundResource(R.drawable.shape_f1f1f3_40);
                }
                getRoom();
                break;
            case R.id.tv_fhwsd_bottom2:
                showDialog();
                if (tvFhwsdBottom2.getCurrentTextColor() == getResources().getColor(R.color.colorTextBlack)) {
                    tvFhwsdBottom2.setTextColor(getResources().getColor(R.color.colorF73637));
                    tvFhwsdBottom2.setBackgroundResource(R.drawable.shape_stroke_pink_solid_white_40);
                } else {
                    tvFhwsdBottom2.setTextColor(getResources().getColor(R.color.colorTextBlack));
                    tvFhwsdBottom2.setBackgroundResource(R.drawable.shape_f1f1f3_40);
                }
                getRoom();
                break;
            case R.id.tv_fhwsd_bottom3:
                showDialog();
                if (tvFhwsdBottom3.getCurrentTextColor() == getResources().getColor(R.color.colorTextBlack)) {
                    tvFhwsdBottom3.setTextColor(getResources().getColor(R.color.colorF73637));
                    tvFhwsdBottom3.setBackgroundResource(R.drawable.shape_stroke_pink_solid_white_40);
                } else {
                    tvFhwsdBottom3.setTextColor(getResources().getColor(R.color.colorTextBlack));
                    tvFhwsdBottom3.setBackgroundResource(R.drawable.shape_f1f1f3_40);
                }
                getRoom();
                break;
            case R.id.tv_fhwsd_bottom4:
                showDialog();
                if (tvFhwsdBottom4.getCurrentTextColor() == getResources().getColor(R.color.colorTextBlack)) {
                    tvFhwsdBottom4.setTextColor(getResources().getColor(R.color.colorF73637));
                    tvFhwsdBottom4.setBackgroundResource(R.drawable.shape_stroke_pink_solid_white_40);
                } else {
                    tvFhwsdBottom4.setTextColor(getResources().getColor(R.color.colorTextBlack));
                    tvFhwsdBottom4.setBackgroundResource(R.drawable.shape_f1f1f3_40);
                }
                getRoom();
                break;
            case R.id.ll_fhwsd_share://分享
                ////2 小区，3 房源 ，7 酒店，52 特卖(预售)
                ShareUtils.getData(this,(AppCompatActivity) getActivity(), "7", hotelID);
                //onScrollWineListener.onChange(1);
                break;
            case R.id.tv_fhwsd_look://查看
                svuFhwsd.smoothScrollTo(0, PhoneUtil.dp2px(getContext(), 180) + getHeight(rlFhwsdInstall));
//                svuFhwsd.smoothScrollTo(0,vwWd.getTop());
                break;
            case R.id.ll_ws_type://档次/开业时间
//                startActivity(OrderDetailsActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("data", new Gson().toJson(mDetailsBody));
                startActivity(InstallationActivity.class, bundle);
                break;
            case R.id.ll_fhwsd_address://定位
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                Uri content_url = Uri.parse(String.format(Constant.URL.MapDiTu, mDetailsBody.getLocation().getLatitude() + "", mDetailsBody.getLocation().getLongitude() + ""
                        , mDetailsBody.getLocation().getAddress(), mDetailsBody.getCity()));
                intent.setData(content_url);
                startActivity(intent);
                break;
            case R.id.tv_fhwsd_more://查看全部
                tvFhwsdIntro.setMaxLines(100);
                tvFhwsdMore.setVisibility(View.GONE);
                break;
            case R.id.ll_fhwsd_user://住离
                createCustomDatePicker(view);
                break;
            case R.id.ll_ws_more://查看更多
                if (listRooms != null && hotelRoomEntity != null) {
                    hotelRoomIsTall = !hotelRoomIsTall;
                    if (hotelRoomIsTall) {
                        listRooms = hotelRoomEntity.getBody();
                        tvWsMore.setText("收起部分房型");
                        ivWsMore.setImageResource(R.drawable.text_down);
                    } else {
                        List<HotelRoomEntity.BodyBean> listRoomsLittle = new ArrayList<>();
                        for (int i = 0; i < mMaxHouseNum; i++) {
                            if (hotelRoomEntity.getBody().size() > i) {
                                listRoomsLittle.add(hotelRoomEntity.getBody().get(i));
                            }
                        }
                        listRooms = listRoomsLittle;
                        tvWsMore.setText("查看剩余" + (hotelRoomEntity.getBody().size() - mMaxHouseNum) + "个房型");
                        ivWsMore.setImageResource(R.drawable.text_up);
                    }
                    findHouseWineShopDetailsAdapter.setData(listRooms);
                }
                break;
        }
    }


    /**
     * 初始化popup
     */
    private void initPopupMore() {
        popuDetails = new CommonPopupWindow(getContext(), R.layout.popu_house_type, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {

            @Override
            protected void initView() {
                try {
                    View view = getContentView();
                    view.findViewById(R.id.tv_ht_confirm).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            skipActivity(mRvPosition, mRvItemPosition);
                            popuDetails.getPopupWindow().dismiss();
                        }
                    });
                    view.findViewById(R.id.tv_dismiss).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            popuDetails.getPopupWindow().dismiss();
                        }
                    });


                    TextView tvConfirm = view.findViewById(R.id.tv_ht_confirm);

                    LinearLayout llPopTitle = (LinearLayout) view.findViewById(R.id.ll_pop_title);

                    TextView tvHtTitle = (TextView) view.findViewById(R.id.tv_ht_title);
                    TextView tvTitle = (TextView) view.findViewById(R.id.tv_pop_title);
                    TextView tvTitleRight = (TextView) view.findViewById(R.id.tv_pop_title_right);
                    TextView tvTitleContent = (TextView) view.findViewById(R.id.tv_pop_title_content);

                    View vwTitleLine = view.findViewById(R.id.vw_title_line);


                    TextView tvPopEat = (TextView) view.findViewById(R.id.tv_pop_eat);
                    TextView tvEatContent = (TextView) view.findViewById(R.id.tv_pop_eat_content);
                    TextView tvBed = (TextView) view.findViewById(R.id.tv_pop_bed);
                    TextView tvBedContent = (TextView) view.findViewById(R.id.tv_pop_bed_content);

                    tvHtTitle.setText(listRooms.get(mRvPosition).getName());

                    tvTitle.setText(listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getBaseDesc().getName());
                    tvTitleRight.setText("(" + listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getName() + ")");
                    tvTitleContent.setText(listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getBaseDesc().getContent());

                    tvPopEat.setText(listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getFoodDesc().getName());
                    String subName = listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getFoodDesc().getSubName().length() == 0 ?
                            listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getFoodDesc().getName() :
                            listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getFoodDesc().getSubName();
                    tvEatContent.setText(subName);

                    tvBed.setText(listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getBedDesc().getName());
                    tvBedContent.setText(listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getBedDesc().getContent());
                    tvConfirm.setText(Html.fromHtml("&yen; " + listRooms.get(mRvPosition).getSalePlans().get(mRvItemPosition).getAveragePriceValue() + "  立即预定"));

                    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv_pop);
                    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));


                    List<HotelRoomEntity.BodyBean.FacilitiesBean> facilities = hotelRoomEntity.getBody().get(mRvPosition).getFacilities();
                    List<DataEntity> dataEntities = new ArrayList<>();
                    if (facilities != null && facilities.size() > 0) {
                        view.findViewById(R.id.tv_pop_base_title).setVisibility(View.VISIBLE);
                        for (int i = 0; i < facilities.size(); i++) {
                            for (int j = 0; j < facilities.get(i).getList().size(); j++) {
                                DataEntity dataEntity = new DataEntity();
                                dataEntity.setTitle(facilities.get(i).getList().get(j).getName());
                                dataEntities.add(dataEntity);
                            }
                        }
                    } else {
                        view.findViewById(R.id.tv_pop_base_title).setVisibility(View.GONE);
                    }

                    PopularHouseAdapter popularHouseAdapter = new PopularHouseAdapter(getContext());
                    recyclerView.setAdapter(popularHouseAdapter);
                    popularHouseAdapter.setData(dataEntities);

                    if (null != hotelRoomEntity.getBody().get(mRvPosition).getImageURLs() && hotelRoomEntity.getBody().get(mRvPosition).getImageURLs().size() > 0) {
                        view.findViewById(R.id.rl_bus).setVisibility(View.VISIBLE);
                        //Banner适配
                        BannerUtils bannerUtils1 = (BannerUtils) view.findViewById(R.id.bus_ht);
                        bannerUtils1.setAdapter(new BannerUtils.Adapter() {
                            @Override
                            public void fillBannerItem(BannerUtils bannerUtils, View itemView, Object model, int position) {
                                RequestOptions options = new RequestOptions()
                                        .error(R.drawable.map_img2x)
                                        .dontAnimate()
                                        .centerCrop()
                                        .placeholder(R.drawable.map_img2x);
                                Glide.with(itemView.getContext())
                                        .load(model)
                                        .apply(options)
                                        .into((ImageView) itemView);
                            }
                        });

                        List<String> urlString = new ArrayList<>();
                        List<String> idString = new ArrayList<>();
                        final List<String> imageURLs = mDetailsBody.getImageURLs();
                        for (int i = 0; i < imageURLs.size(); i++) {
                            urlString.add(mDetailsBody.getImageURLs().get(i));
                            idString.add("空的");
                        }
                        bannerUtils1.setData(R.layout.view_image_circle, urlString, idString);

                        tvGuideMore = (TextView) view.findViewById(R.id.tv_guide);
                        bannerUtils1.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                            @Override
                            public void onPageScrolled(int i, float v, int i1) {
                                if (v % 1 > 0.1 && imageURLs.size() > i + 1) {
                                    tvGuideMore.setText(i + 2 + "/" + imageURLs.size());
                                } else {
                                    tvGuideMore.setText(i + 1 + "/" + imageURLs.size());
                                }
                            }

                            @Override
                            public void onPageSelected(int i) {

                            }

                            @Override
                            public void onPageScrollStateChanged(int i) {

                            }
                        });
                    } else {
                        view.findViewById(R.id.rl_bus).setVisibility(View.GONE);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            protected void initEvent() {
                WindowManager.LayoutParams attributes = getActivity().getWindow().getAttributes();
                attributes.alpha = 0.3f;
                getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                getActivity().getWindow().setAttributes(attributes);
            }
        };
        popuDetails.getPopupWindow().setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                WindowManager.LayoutParams attributes = getActivity().getWindow().getAttributes();
                attributes.alpha = 1.0f;
                getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                getActivity().getWindow().setAttributes(attributes);
            }
        });
        popuDetails.showAtLocation(llFwd, Gravity.BOTTOM, 0, 0);
    }


    /**
     * 初始化相似列表
     */
    private void getSimilar() {
        Map<String, String> map = new HashMap<>();
        OkHttpUtil.getJSON(getContext(), String.format(Constant.URL.hotelSimilar, hotelID), map, new OkHttpUtil.OnDataListener() {
            @Override
            public void onResponse(String url, String json) {
                try {
                    LogUtil.jLog().e(json);
                    dismissDialogAndRefresh();
                    mHotelSimilyEntity = new Gson().fromJson(json, HotelSimilyEntity.class);
                    if (mHotelSimilyEntity.getCode().equals(Constant.Strings.SUC)) {
                        list = mHotelSimilyEntity.getBody().getList();
                        if (list.size() != 0) {
                            findHouseWindShopNearAdapter.setData(list);
                            rvFhwsdNear.setVisibility(View.VISIBLE);
                        } else {
                            tvFhwsdNear.setVisibility(View.GONE);
                            rvFhwsdNear.setVisibility(View.GONE);
                        }
                    } else {
                        tvFhwsdNear.setVisibility(View.GONE);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onFailure(String url, String error) {

            }
        });
    }


    /**
     * 查询酒店房型列表
     */
    private void getRoom() {
        Map<String, String> map = new HashMap<>();
        LogUtil.jLog().e(checkInDate + "   " + checkOutDate);
        map.put("checkInDate", checkInDate);
        map.put("checkOutDate", checkOutDate);
        String types = "";
        if (tvFhwsdBottom1.getCurrentTextColor() != getResources().getColor(R.color.colorTextBlack)) {
            types = 1 + "";
        }
        if (tvFhwsdBottom2.getCurrentTextColor() != getResources().getColor(R.color.colorTextBlack)) {
            if (types.length() != 0) {
                types = types + "," + 2;
            } else {
                types = 2 + "";
            }
        }
        if (tvFhwsdBottom3.getCurrentTextColor() != getResources().getColor(R.color.colorTextBlack)) {
            if (types.length() != 0) {
                types = types + "," + 3;
            } else {
                types = 3 + "";
            }
        }
        if (tvFhwsdBottom4.getCurrentTextColor() != getResources().getColor(R.color.colorTextBlack)) {
            if (types.length() != 0) {
                types = types + "," + 4;
            } else {
                types = 4 + "";
            }
        }

        LogUtil.jLog().e(types);
        if (types.length() != 0) {
            map.put("types", types);
        }
        OkHttpUtil.getJSON(getContext(), String.format(Constant.URL.rooms, hotelID), map, new OkHttpUtil.OnDataListener() {

            @Override
            public void onResponse(String url, String json) {
                try {
                    LogUtil.jLog().e(json);
                    dismissDialogAndRefresh();
                    hotelRoomEntity = new Gson().fromJson(json, HotelRoomEntity.class);
                    if (hotelRoomEntity.getCode().equals(Constant.Strings.SUC)) {
                        for (int i = 0; i < hotelRoomEntity.getBody().size(); i++) {
                            hotelRoomEntity.getBody().get(i).setOpen(false);
                            hotelRoomEntity.getBody().get(i).setItemOpen(false);
                            hotelRoomEntity.getBody().get(i).setVip(hotelVip);
                            if (!tvFhwsdDay.getText().toString().equals("1晚")) {
                                hotelRoomEntity.getBody().get(i).setMoreDay(true);
                            } else {
                                hotelRoomEntity.getBody().get(i).setMoreDay(false);
                            }

                            for (int j = 0; j < hotelRoomEntity.getBody().get(i).getSalePlans().size(); j++) {
                                hotelRoomEntity.getBody().get(i).getSalePlans().get(j).setVip(hotelVip);
                                if (!tvFhwsdDay.getText().toString().equals("1晚")) {
                                    hotelRoomEntity.getBody().get(i).getSalePlans().get(j).setMorDay(true);
                                } else {
                                    hotelRoomEntity.getBody().get(i).getSalePlans().get(j).setMorDay(false);
                                }
                            }
                        }

                        if (hotelRoomEntity.getBody().size() > mMaxHouseNum) {
                            llWsMore.setVisibility(View.VISIBLE);
                            ivWsMore.setVisibility(View.VISIBLE);
                            tvWsMore.setText("查看剩余" + (hotelRoomEntity.getBody().size() - mMaxHouseNum) + "个房型");

                            if (listRooms.size() > 0) {
                                listRooms.clear();
                            }
                            for (int i = 0; i < mMaxHouseNum; i++) {
                                listRooms.add(hotelRoomEntity.getBody().get(i));
                            }
                        } else {
                            llWsMore.setVisibility(View.GONE);
                            if (hotelRoomEntity.getBody().size() == 0) {
                                llWsMore.setVisibility(View.VISIBLE);
                                tvWsMore.setText("没有房型列表");
                                ivWsMore.setVisibility(View.GONE);
                            }
                            listRooms = hotelRoomEntity.getBody();
                        }
                        findHouseWineShopDetailsAdapter.setData(listRooms);


//                        LogUtil.jLog().e(getHeight(rlFhwsdInstall) + "   " + getHeight(llFhwsdLabel) + "    " + getHeight(llFhwsdUser) + "   " + getHeight(rvFhwsd));
                        mHearHeight = PhoneUtil.dp2px(getActivity(), 265)
                                + getHeight(rlFhwsdInstall) + getHeight(llFhwsdLabel) + getHeight(llFhwsdUser) + getHeight(rvFhwsd);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(String url, String error) {

            }
        });
    }


    /**
     * 初始化Banner
     */
    private void initBanner() {
        //Banner适配
        busWs.setAdapter(new BannerUtils.Adapter() {
            @Override
            public void fillBannerItem(BannerUtils bannerUtils, View itemView, Object model, int position) {
                RequestOptions options = new RequestOptions()
                        .error(R.drawable.map_img2x)
                        .dontAnimate()
                        .centerCrop()
                        .placeholder(R.drawable.map_img2x);
                Glide.with(itemView.getContext())
                        .load(model)
                        .apply(options)
                        .into((ImageView) itemView);
            }
        });
    }


    /**
     * 初始化列表
     */
    private void initSimilyRv() {
        rvFhwsdNear.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        findHouseWindShopNearAdapter = new FindHouseWindShopNearAdapter(getContext());
        rvFhwsdNear.setAdapter(findHouseWindShopNearAdapter);
        findHouseWindShopNearAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                Intent intent = new Intent(getActivity(), WineShopDetailsActivity.class);
                intent.putExtra("hotelId", mHotelSimilyEntity.getBody().getList().get(position).getId());
                intent.putExtra("distance1", "0");
                LogUtil.jLog().e(SharedPreferencesUtil.getDistance(getContext()) + "");
                if (SharedPreferencesUtil.getDistance(getContext()) != 0) {
                    SharedPreferencesUtil.saveDistance1(getContext(), SharedPreferencesUtil.getDistance(getContext()));
                }
                startActivityForResult(intent, 0x009);

            }
        });
    }

    private void initBranList() {
        rvFhwsdSimilar.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        mFindHousBrandListAdapter = new FindHousBrandListAdapter(getContext());
        rvFhwsdSimilar.setAdapter(mFindHousBrandListAdapter);
        mFindHousBrandListAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                Intent intent = new Intent(getActivity(), WineShopDetailsActivity.class);
                intent.putExtra("hotelId", mBrandList.get(position).getId());
                intent.putExtra("distance1", "0");
                if (SharedPreferencesUtil.getDistance(getContext()) != 0) {
                    SharedPreferencesUtil.saveDistance1(getContext(), SharedPreferencesUtil.getDistance(getContext()));
                }
                startActivityForResult(intent, 0x009);
            }
        });
    }

    /**
     * 初始化上面的列表
     */
    private void initRoomRv() {
        linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
        rvFhwsd.setLayoutManager(linearLayoutManager);

        findHouseWineShopDetailsAdapter = new FindHouseWineShopDetailsAdapter(getContext(), new View.OnClickListener() {
            @Override
            public void onClick(View v) {//外层预订点击事件
                int position = (int) v.getTag();
                switch (v.getId()) {
                    case R.id.ll_fhwsd_money://展开
                        listRooms.get(position).setOpen(!listRooms.get(position).isOpen());
                        findHouseWineShopDetailsAdapter.setData(listRooms);
                        break;
                    case R.id.ll_fhwsd_more://查看更多
                        for (int i = 0; i < hotelRoomEntity.getBody().size(); i++) {
                            hotelRoomEntity.getBody().get(position).setItemOpen(true);
                            listRooms.get(position).setItemOpen(true);
                        }
                        findHouseWineShopDetailsAdapter.setData(listRooms);
                        break;
                    case R.id.tv_fhwsd_confirm://预订
                        skipActivity(position, 0);
                        break;
                }
            }
        });


        findHouseWineShopDetailsAdapter.setOnEnergyItemClickListener(new FindHouseWineShopDetailsAdapter.OnItemPositionClickListener() {
            @Override
            public void onItemPositionClick(View view, int position, int itemPosition) {
                switch (view.getId()) {
                    case R.id.tv_fi_confirm:
                        skipActivity(position, itemPosition);
                        break;
                    case R.id.rl_item:
                        mRvPosition = position;
                        mRvItemPosition = itemPosition;
                        initPopupMore();
                        break;
                }

            }
        });


        rvFhwsd.setAdapter(findHouseWineShopDetailsAdapter);
        findHouseWineShopDetailsAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                mRvPosition = position;
                mRvItemPosition = 0;
                if (hotelRoomEntity.getBody().get(position).getSalePlans().size() > 1) {
                    listRooms.get(position).setOpen(!listRooms.get(position).isOpen());
                    findHouseWineShopDetailsAdapter.setData(listRooms);
                } else {
                    initPopupMore();
                }
            }
        });
    }


    /**
     * 同品牌酒店
     */
    private void getBrandList() {
        Map<String, String> map = new HashMap<>();
        OkHttpUtil.getJSON(getContext(), String.format(Constant.URL.brandList, hotelID), map, new OkHttpUtil.OnDataListener() {

            @Override
            public void onResponse(String url, String json) {
                try {
                    LogUtil.jLog().e(json);
                    dismissDialogAndRefresh();
                    BrandListEntity brandListEntity = new Gson().fromJson(json, BrandListEntity.class);
                    if (brandListEntity.getCode().equals(Constant.Strings.SUC) && brandListEntity.getBody().getList().size() != 0) {
                        rvFhwsdSimilar.setVisibility(View.VISIBLE);
                        tvFhwsdSimilar.setVisibility(View.VISIBLE);
                        vwFhwsdSimilar.setVisibility(View.VISIBLE);

                        mBrandList = brandListEntity.getBody().getList();
                        mFindHousBrandListAdapter.setData(mBrandList);
                    } else {
                        rvFhwsdSimilar.setVisibility(View.GONE);
                        tvFhwsdSimilar.setVisibility(View.GONE);
                        vwFhwsdSimilar.setVisibility(View.GONE);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(String url, String error) {

            }
        });
    }


    public void skipActivity(int position, int itemPosition) {
        Bundle bundle = new Bundle();
        bundle.putString("checkOutDate", checkOutDate);
        bundle.putString("checkInDate", checkInDate);
        bundle.putString("inDay", tvFhwsdDay.getText().toString());
        bundle.putString("dataDetails", new Gson().toJson(mDetailsBody));
        bundle.putInt("position", itemPosition);
        bundle.putString("data", new Gson().toJson(hotelRoomEntity.getBody().get(position)));
        startActivity(OrderInputActivity.class, bundle);
    }

    /**
     * 日历
     */
    private void createCustomDatePicker(View view) {
        builder = new DatePopupWindow
                .Builder(getActivity(), Calendar.getInstance().getTime(), view)
                .setInitSelect(startGroup, startChild, endGroup, endChild)
                .setInitDay(false)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (v.getId() == R.id.btn_clear) {
                            checkInDate = "";
                            checkOutDate = "";
                            startGroup = -1;
                            startChild = -1;
                            endGroup = -1;
                            endChild = -1;
                        }
                    }
                })
                .setDateOnClickListener(new DatePopupWindow.DateOnClickListener() {
                    @Override
                    public void getDate(String startDate, String endDate, int startGroupPosition, int startChildPosition, int endGroupPosition, int endChildPosition) {
                        startGroup = startGroupPosition;
                        startChild = startChildPosition;
                        endGroup = endGroupPosition;
                        endChild = endChildPosition;


                        String mStartTime = CalendarUtil.FormatDateMD(startDate);
                        String mEndTime = CalendarUtil.FormatDateMD(endDate);
                        checkInDate = addData(startDate);
                        checkOutDate = addData(endDate);

                        tvFhwsdIn.setText(mStartTime);
                        tvFhwsdOut.setText(mEndTime);

                        getRoom();
                    }
                }).builder();

        builder.setOnDismissListener(new BasePopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                tvFhwsdDay.setText(builder.getTime());
            }
        });
    }

    public int getHeight(View view) {
        int width = View.MeasureSpec.makeMeasureSpec(0,
                View.MeasureSpec.UNSPECIFIED);
        int height = View.MeasureSpec.makeMeasureSpec(0,
                View.MeasureSpec.UNSPECIFIED);
        view.measure(width, height);
        view.getMeasuredWidth(); // 获取宽度
        view.getMeasuredHeight(); // 获取高度
//        LogUtil.jLog().e(rlFhwsdInstall.getMeasuredHeight() + "  " + rlFhwsdInstall.getMeasuredWidth());
        return view.getMeasuredHeight();
    }


    public String addData(String data) {
        String[] split = data.split("-");
        if (split[1].length() == 1) {
            split[1] = "0" + split[1];
        }
        if (split[2].length() == 1) {
            split[2] = "0" + split[2];
        }
        return split[0] + "-" + split[1] + "-" + split[2];
    }

    /**
     * 停止加载框
     */
    protected void dismissDialogAndRefresh() {
        if (loadDialog != null) {
            loadDialog.dismiss();//获取信息后关闭对话框
        }
        if (srlFwsdh != null && srlFwsdh.isRefreshing()) {
            srlFwsdh.setRefreshing(false);
        }
    }

    /**
     * 设置加载框
     */
    protected void showDialog() {
        if (loadDialog == null) {
            loadDialog = LoadDialog.newInstance("加载中");
        }
        loadDialog.show(getActivity().getSupportFragmentManager(), "loading");
    }


    @Override
    public void onResume() {
        super.onResume();
        if (SharedPreferencesUtil.getDistance(getActivity()) != 0 && SharedPreferencesUtil.getDistance(getActivity()) != -1) {
            svuFhwsd.setScrollY(SharedPreferencesUtil.getDistance(getActivity()));
        }
        dismissDialogAndRefresh();
    }

    @Override
    public void onPause() {
        super.onPause();
        if (SharedPreferencesUtil.getDistance(getActivity()) != 0 && SharedPreferencesUtil.getDistance(getActivity()) != -1) {
            svuFhwsd.setScrollY(SharedPreferencesUtil.getDistance(getActivity()));
        }
    }

    private onScrollWineListener onScrollWineListener;

    public void setOnScrollWineListener(onScrollWineListener onScrollWineListener) {
        this.onScrollWineListener = onScrollWineListener;
    }

    @Override
    public boolean onBackPressed() {
        if (vImageWatcher == null) {
            return false;
        } else {
            // 当确认没有子Fragmnt时可以直接return false
            if (!vImageWatcher.handleBackPressed()) {
                return BackHandlerHelper.handleBackPress(this);
            } else {
                return !BackHandlerHelper.handleBackPress(this);
            }
        }
    }

    public interface onScrollWineListener {
        void onScroll(int scrollY, int height, int type);

        void onChange(int i);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 0x0009) {
            if (SharedPreferencesUtil.getDistance1(getActivity()) != 0 || SharedPreferencesUtil.getDistance1(getActivity()) != -1) {
                svuFhwsd.setScrollY(SharedPreferencesUtil.getDistance1(getActivity()));
                SharedPreferencesUtil.saveDistance(getContext(), SharedPreferencesUtil.getDistance1(getActivity()));
            }
        }
    }
}
